﻿/*

  The contents of this file are subject to the Mozilla Public License Version
  1.1 (the "License"); you may not use this file except in compliance with
  the License. You may obtain a copy of the License at 
  
           http://www.mozilla.org/MPL/ 
  
  Software distributed under the License is distributed on an "AS IS" basis,
  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  for the specific language governing rights and limitations under the License. 
  
  The Original Code is PEGAS Framework.
  
  The Initial Developer of the Original Code is
  ALCARAZ Marc (aka eKameleon)  <vegas@ekameleon.net>.
  Portions created by the Initial Developer are Copyright (C) 2004-2009
  the Initial Developer. All Rights Reserved.
  
  Contributor(s) :
  
*/
package pegas.geom 
{
    import buRRRn.ASTUce.framework.TestCase;

    public class UVTest extends TestCase 
	{
        public function UVTest(name:String = "")
        {
            super( name );
        }
        
        public var c:UV ;
    
        public function setUp():void
        {
            c = new UV(10, 20) ;
        }
        
        public function tearDown():void
        {
            c = undefined ;
        }
        
        public function testConstructor():void
        {
            assertNotNull( c, "01 - constructor is null") ;
            assertTrue( c is UV , "02 - constructor is an instance of UVCoordinate.") ;
        }
        
        public function testInterface():void
        {
            assertTrue( c is Geometry  , "must implements the Geometry interface.") ;
        }   
        
        public function testToSource():void
        {   
            assertEquals( c.toSource() , "new pegas.geom.UV(10,20)", "toSource failed : " + c.toSource() ) ;
        }
        
        public function testToString():void
        {
            assertEquals( c.toString() , "[UV u:10 v:20]", "toString failed : " + c.toString() ) ;
        }
        
        public function testU():void
        {
            assertEquals( c.u , 10, "u property failed : " + c.u ) ;
        }
        
        public function testV():void
        {
            assertEquals( c.v , 20, "v property failed : " + c.v ) ;
        }
        
        public function testClone():void
        {
            var clone:UV = c.clone() as UV ;
            
            assertNotNull( clone , "01 - clone method failed, must return a UV reference." ) ;
            
            clone.u = 100 ;
            clone.v = 200 ;
            
            assertFalse( c.u == clone.u, "02-01 - clone failed, v.x:" + c.u + " must be different of clone.x:" + clone.u ) ;
            assertFalse( c.v == clone.v, "02-02 - clone failed, v.y:" + c.v + " must be different of clone.x:" + clone.v ) ;
        }
                
        public function testEquals():void
        {
            var uv:UV = new UV(10, 20) ;
            assertTrue( c.equals(uv) , "equals method failed.") ;
        }
    }
}